package org.example.controller;

import org.example.utils.Result;
import org.example.model.Sysrole;
import org.example.service.ResourcesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


//定义表现层控制器bean
@Controller
@ResponseBody
@RequestMapping("/save")
public class UserController {

    @Autowired
    private ResourcesService resourcesService;


    @GetMapping
    public List<Sysrole> save(){
        List<Sysrole> list = resourcesService.save();
        return list;
    }

    //模糊查询
    @GetMapping("/{rolename}")
    public List<Sysrole> save(@PathVariable String rolename){
        System.out.println(rolename);
        List<Sysrole> list = resourcesService.save();
        return list;
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id){
        return Result.success("删除成功",2000,id);
    }

    @PostMapping
    public Result add(@RequestBody Sysrole sysrole){
        return Result.success("添加成功",2000);
    }

    @PutMapping
    public Result update(@RequestBody Sysrole sysrole){
        return Result.success("编辑成功",2000);
    }

}
